<?php
namespace Biz\model;

use Doraemon\pockets\datebase\BaseDbModel;

class ShopSwitch extends BaseDbModel
{
	const _CONFIG_FILE_ = 'db_shop';

	const _CONFIG_SELECT_ = 'db_shop';

	const _DATABASE_ = 'shop';

	const _TABLE_NAME = 'shop_switch';

	const SWITCH_ON = 1;
	const SWITCH_OFF = 0;

	const TYPE_HOT_GOODS = 1;
	const TYPE_COUPON = 2;

	const MAP_TYPE_FIELDS = [
	    self::TYPE_HOT_GOODS => 'is_show_hotgoods',
        self::TYPE_COUPON => 'is_show_coupon'
    ];


	public static function is_show_hotGoods($uid)
	{
		$info = self::get_master('*', [
			'shop_id' => $uid,
		]);

		if ($info) {
			return $info['is_show_hotgoods'] ? true : false;
		} else {
			//默认 显示
			return true;
		}
	}

	public static function is_show_coupon($uid)
    {
        $info = self::get_master('*', [
            'shop_id' => $uid
        ]);
        if ($info) {
            return $info['is_show_coupon'] ? true : false;
        } else {
            return false;
        }
    }



	public static function getInfo($uid)
	{
		return self::get('*', [
			'shop_id' => $uid
		]);
	}

	public static function updateData($uid, $data)
	{

		return self::update($data, ['shop_id' => $uid]);
	}

	public static function insertData($uid, $data)
	{

		$data['shop_id'] = $uid;
		self::insert($data);

		return self::id();

	}

}
